const path = require('path');

const glob = require('glob');
const Router = require('koa-router');

const router = new Router();

module.exports = app => {
  glob(path.join(__dirname, '*.js'), (err, files) => {
    files.forEach(file => {
      if (path.basename(file) != 'index.js') {
        require(file)(router);
      }
    });
  });
  app.use(router.routes());
  app.use(router.allowedMethods());
}
